home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-02-09 | 4.9 KB | 175 lines | [TEXT/R*ch] |
- /*
- File: CDefensePanel.h
-
- Contains: Class stub to use as a template for creating your own multi-pane
- dialog panels.
-
- Written by: Mike Shields
-
- Copyright: Copyright © 1996 Mike Shields. All Rights Reserved.
-
- Change History (most recent first):
-
- 02/01/96 MSS New
- To Do:
- */
- #include "CDefensePanel.h"
-
- #include <LStream.h>
- #include <LControl.h>
-
- struct SDefensePanelRec
- {
- Int16 photons;
- Int16 enableBoom;
- Int16 boom;
- Int16 shields;
- };
-
- typedef struct SDefensePanelRec DefensePanelDataRec, *DefensePanelDataPtr, **DefensePanelDataHandle;
-
- //---------------------------------------------------------------------------
- // CDefensePanel::CreateFromStream
- //---------------------------------------------------------------------------
- CDefensePanel* CDefensePanel::CreateFromStream(LStream* inStream)
- {
- return (new CDefensePanel(inStream));
- }
-
- //---------------------------------------------------------------------------
- // CDefensePanel::CDefensePanel
- //---------------------------------------------------------------------------
- CDefensePanel::CDefensePanel()
- {
- }
-
- //---------------------------------------------------------------------------
- // CDefensePanel::CDefensePanel
- //---------------------------------------------------------------------------
- CDefensePanel::CDefensePanel(const CDefensePanel &inOriginal)
- : CMPDPanel(inOriginal)
- {
- }
-
- //---------------------------------------------------------------------------
- // CDefensePanel::CDefensePanel
- //---------------------------------------------------------------------------
- CDefensePanel::CDefensePanel(const SPaneInfo &inPaneInfo, const SViewInfo &inViewInfo)
- : CMPDPanel(inPaneInfo, inViewInfo)
- {
- }
-
- //---------------------------------------------------------------------------
- // CDefensePanel::CDefensePanel
- //---------------------------------------------------------------------------
- CDefensePanel::CDefensePanel(LStream *inStream)
- : CMPDPanel(inStream)
- {
- }
-
- //---------------------------------------------------------------------------
- // CDefensePanel::CDefensePanel
- //---------------------------------------------------------------------------
- CDefensePanel::~CDefensePanel()
- {
- }
-
- //---------------------------------------------------------------------------
- // CDefensePanel::GetData
- //---------------------------------------------------------------------------
- void CDefensePanel::FinishCreateSelf()
- {
- LControl *aControl;
- aControl = (LControl*)this->FindPaneByID('Eslf');
- aControl->AddListener(this);
- }
-
- //---------------------------------------------------------------------------
- // CDefensePanel::GetData
- //---------------------------------------------------------------------------
- void CDefensePanel::ListenToMessage(MessageT inMessage, void *ioParam)
- {
- switch ( inMessage )
- {
- case 'Eslf':
- {
- LControl *aControl;
- aControl = (LControl*)this->FindPaneByID('Self');
- if ( *(Int32*)ioParam == 1 )
- {
- aControl->Enable();
- }
- else
- {
- aControl->Disable();
- }
- break;
- }
- }
- }
-
- //---------------------------------------------------------------------------
- // CDefensePanel::GetData
- //---------------------------------------------------------------------------
- void CDefensePanel::GetData(Handle inDataToReplace)
- {
- LControl *aControl;
- DefensePanelDataRec newPrefs;
-
- aControl = (LControl*)this->FindPaneByID('EPho');
- newPrefs.photons = aControl->GetValue();
- aControl = (LControl*)this->FindPaneByID('Eslf');
- newPrefs.enableBoom = aControl->GetValue();
- if ( newPrefs.enableBoom == 1 )
- {
- aControl = (LControl*)this->FindPaneByID('Self');
- newPrefs.boom = aControl->GetValue();
- }
- else
- newPrefs.boom = 0;
- aControl = (LControl*)this->FindPaneByID('Off ');
- if ( aControl->GetValue() == 1 )
- newPrefs.shields = 1;
- else
- {
- aControl = (LControl*)this->FindPaneByID('On ');
- if ( aControl->GetValue() == 1 )
- newPrefs.shields = 2;
- else
- newPrefs.shields = 3;
- }
-
- OSErr anErr = ::PtrToXHand(&newPrefs, inDataToReplace, sizeof(newPrefs));
- ThrowIfOSErr_(anErr);
- }
-
- //---------------------------------------------------------------------------
- // CDefensePanel::SetData
- //---------------------------------------------------------------------------
- void CDefensePanel::SetData(Handle inData)
- {
- LControl *aControl;
- DefensePanelDataHandle newPrefs = (DefensePanelDataHandle)inData;
-
- aControl = (LControl*)this->FindPaneByID('EPho');
- aControl->SetValue((**newPrefs).photons);
- aControl = (LControl*)this->FindPaneByID('Eslf');
- aControl->SetValue((**newPrefs).enableBoom);
- aControl = (LControl*)this->FindPaneByID('Self');
- if ( (**newPrefs).enableBoom == 1 )
- aControl->SetValue((**newPrefs).boom);
- else
- {
- aControl->Disable();
- aControl->SetValue(0);
- }
-
- aControl = (LControl*)this->FindPaneByID('Off ');
- aControl->SetValue((**newPrefs).shields == 1 ? 1 : 0);
- aControl = (LControl*)this->FindPaneByID('On ');
- aControl->SetValue((**newPrefs).shields == 2 ? 1 : 0);
- aControl = (LControl*)this->FindPaneByID('High');
- aControl->SetValue((**newPrefs).shields == 3 ? 1 : 0);
- }
-
-